<template>
  <div class="icons-container">
    <div v-for="item of state.svgIcons" :key="item" class="icon-item">
      <el-tooltip class="item" effect="dark" placement="top">
        <template #content> {{ `<svg-icon name="${item}" />` }} </template>
        <svg-icon :name="item" />
      </el-tooltip>
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script setup>
import { reactive, onBeforeMount } from 'vue'

const state = reactive({
  svgIcons: []
})
function getSvgIcons() {
  const req = import.meta.glob('/src/icons/*.svg')
  state.svgIcons = Object.keys(req).map((res) => {
    return res.replace('/src/icons/', '').replace('.svg', '')
  })
}
onBeforeMount(() => {
  getSvgIcons()
})
</script>

<style lang="scss" scoped>
.icons-container {
  padding: 30px;
  .icon-item {
    margin: 20px;
    height: 85px;
    text-align: center;
    width: 100px;
    float: left;
    font-size: 50px;
    color: #24292e;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    span {
      line-height: 30px;
      font-size: 14px;
    }
  }
}
</style>
